package com.ict.ycwl.user.service.impl;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.ict.ycwl.user.pojo.User;
import com.ict.ycwl.user.service.TokenService;
import org.springframework.stereotype.Service;

@Service
public class TokenServiceImpl implements TokenService {
    @Override
    public String getToken(User user) {
        return JWT.create()
                .withClaim("userId", String.valueOf(user.getUserId()))
                .withClaim("userName", user.getUserName())
                .withClaim("LoginName", user.getLoginName())
                .withClaim("password", user.getPassword())
                .withClaim("roleId",user.getRoleId())
                .withClaim("workNumber",user.getWorkNumber())
                .sign(Algorithm.HMAC256(user.getPassword()));
    }
}
